package codingDudes.utils;

/**
 * This class provides methods for conversion between metrical and screenbased values.
 * 
 * The conversion ratio can be changed using the method setPixelToMillimeterRatio(double).
 * The default conversion ratio is set to fit the Setting of the Maeve Multitoch-Table.
 * 
 * @author Tobias Friese
 */

public class Measurement
{
	// maeve ratio by default
	private static double PIXEL_TO_MILLIMETER_RATIO = 0.833333333333333d;
	
	/**
	 * Converts from pixel to millimeter
	 * 
	 * @param pixel pixel value
	 * @return millimeter value
	 */
	public static double pixelToMillimeter(double pixel)
	{
		return (pixel * PIXEL_TO_MILLIMETER_RATIO);
	}
	
	/**
	 * Converts from millimeter to pixel
	 * 
	 * @param millimeter millimeter value
	 * @return pixel value
	 */
	public static double millimeterToPixel(double millimeter)
	{
		return (millimeter / PIXEL_TO_MILLIMETER_RATIO);
	}
	
	/* getter setter */
	
	/** Returns the conversion ratio currently set. */
	public static double getPixelToMillimeterRatio()
	{
		return PIXEL_TO_MILLIMETER_RATIO;
	}
	
	/** Defines the conversion ratio to calculate with. */
	public static void setPixelToMillimeterRatio(double value)
	{
		PIXEL_TO_MILLIMETER_RATIO = value;
	}
}
